home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / PGM_TOOL / PREVIEW / SAMPLES / JCCOMMON.PAS < prev    next >
Pascal/Delphi Source File  |  1995-10-29  |  52KB  |  1,872 lines

  1. unit JcCommon;
  2.  
  3. interface
  4.  
  5. Uses SysUtils,Classes,DBFserver,CommonCode;
  6.  
  7. Const CRMAX=30;
  8.             MaxDue=75;
  9.       MaxTools=25;
  10.             MaxLots=100;
  11.             MaxDeps=45;
  12.  
  13. type
  14.   JCMainRec=Class(TObject)
  15.     public
  16.         qcgang:string[70];
  17.         { Job Inquiry DBF's }
  18.         jobs,due,ship,labor,outside,cust,parts:oDB;
  19.         tools,jipinfo,invshelf,assembly,jobitems:oDB;
  20.         invmat,outjobs,poprcdel,outpo,vendors:oDB;
  21.         matspecs,porders,crosref,packets:oDB;
  22.         { following used by cross ref. routines }
  23.     crcnt,crroot,mcrcnt,mcrroot:integer;
  24.        crmaincn,crorgcn,crosnode,mcrmaincn,mcrorgcn,mcrosnode:string[6];
  25.       crmainpn,crorgpn,mcrmainpn,mcrorgpn:string[20];
  26.         crcust,mcrcust:array [1..CRMAX] of string[6];
  27.         crmain,mcrmain:array [1..CRMAX] of boolean;
  28.         crnote,mcrnote:array [1..CRMAX] of string[60];
  29.         crpn,mcrpn:array [1..CRMAX] of string[20];
  30.         crrec,mcrrec:array [1..CRMAX] of longint;
  31.     clist:array [1..30] of string[6];
  32.     olots,suffixes:array [1..MaxLots] of string[3];
  33.       depcnt:integer;
  34.         depcode:array [1..MaxDeps] of string10;
  35.         depname:array [1..MaxDeps] of string80;
  36.         constructor Create;
  37.         function  croscust(pnum:string;aliasname,history,cust:oDB;
  38.             pnsrc:boolean):string;
  39.         function  crosload(partnum,custnum:string;crosref:oDB):boolean;
  40.         procedure flagstpos(job_num:string;stype:array of integer);
  41.         function  mcrosload(partnum,custnum:string;crosmat:oDB):boolean;
  42.         function  oldlots(orgpo:string):string;
  43.         function  Endlot(curlot:string;shiftup:boolean):string;
  44.         procedure LoadDepList;
  45.     function  vdiv( dnum:string ):boolean;
  46.     function  ndiv( dnum:string ):string;
  47.     function  rngdep( subnum:integer ):string;
  48.     function  vdep( dnum:integer ):boolean;
  49.     function  pdep( dnum:string ):integer;
  50.     function  ndep( dnum:string ):string;
  51.   end;
  52.   JobRec=Class(TObject)
  53.     public
  54.       { oDB's used by "Load()", must be open }
  55.     jobs,due,ship,cust,parts,jipinfo,jobitems:oDB;
  56.       { oDB's to used by "LoadInv", only open as needed }
  57.         labor,outside,tools,invshelf,assembly:oDB;
  58.         invmat,outjobs,poprcdel,outpo,vendors:oDB;
  59.         matspecs,porders,crosref,packets:oDB;
  60.     { the following are the original values,
  61.       reset to these if a change is aborted }
  62.     { drecs[] always contains the current list of due records }
  63.     oscnt,ocnt,ojstatus:integer;
  64.     odates:array [1..MaxDue] of longint;
  65.     odqty:array [1..MaxDue] of double;
  66.     oqty,ouprice:double;
  67.     oponum:string[32];
  68.     orevnum:string[12];
  69.     omotdate,ostatdate:longint;
  70.     { the following may be changed }
  71.     jobnum,joblink,revnum,custref,depnum,barfai,waitstatus:string[12];
  72.     billnum,lineitem,shipnum,custnum,clozapprov,lotmadeto:string[6];
  73.         lotinspto,lotshipto:string[6];
  74.     partname,buyer,custname,partnum,ponum,tobpless:string[40];
  75.     qty,orgqty,uprice,addon,totdue,totship,material:double;
  76.         otherup,otherchgs,mater_est,proc_est,labor_est,bid,complete,partial:double;
  77.         othertext:string;
  78.         uptext,note1,note2,note3:string[60];
  79.     tcnt,dcnt,scnt,jstatus,StillDue,matsel,procsel:integer;
  80.         recnum,orderdate,motdate,statdate,setupdate,porecdate,lastchange:longint;
  81.     SaveData,taxable,ourmat,tobp,islocked:boolean;
  82.     jobchg,duechg,shipchg,jipchg,itemschg:boolean;
  83.     divname,depname,invless:string[30];
  84.     { following used to track special cost items }
  85.     specitem:array [1..3] of string[5];
  86.     speccom:array [1..3] of string[25];
  87.     specup:array [1..3] of double;
  88.     specper:array [1..3] of string[3];
  89.     ttrems:array [1..5] of string[30]; {trip ticket remarks}
  90.         mat1,mat2:string[35];
  91.     sinv,ddates,sdates,drecs,srecs:array [1..MaxDue] of longint;
  92.     sshippr:array [1..MaxDue] of string[15];
  93.     dqty,sqty:array [1..MaxDue] of double;
  94.     dstat:array [1..MaxDue] of integer;
  95.     slot,svia:array [1..MaxDue] of string[5];
  96.     toolsa:array [1..MaxTools] of string[30];
  97.         constructor Create;
  98.         function  Load(jbnum:string;WithLock:boolean):boolean;
  99.         procedure Save;
  100.         procedure QuickInfo;  { report }
  101.         procedure LoadInv(var totdone,totless:longint;
  102.             var InvStr:array of string135;var invcnt:integer);
  103.         procedure ChkRevNo(forpn:string);
  104.         procedure LdmSpec(var rtt,rtt2:string);
  105.         procedure RunBal(rettot:double;
  106.             var InvStr:array of string135;var atpos:integer;maxents:integer);
  107.   end;
  108.  
  109. procedure StartJCcommon;
  110. procedure StopJCcommon;
  111. function  fCurLot(apat:string):integer;
  112. function  GetJStatus(jstat:integer;statdate:longint):String;
  113. procedure CrosGroup(frominv:boolean;var tcustname,tcustnum,tourvend:string);
  114. function  ShortEName(ename:string;lnamelen:integer):string;
  115. function  WaitCode(mwait:string):string;
  116.  
  117. var jcm:JCMainRec;
  118.  
  119. implementation
  120.  
  121. uses wPreview,wAboutbx;
  122.  
  123. procedure StartJCcommon;
  124. begin
  125.   ClearFlagUse;  { at startup }
  126.   jcm:=JCMainRec.Create;
  127. end;
  128.  
  129. constructor JobRec.Create;
  130. begin
  131.     jobs:=Nil;
  132.     due:=Nil;
  133.     ship:=Nil;
  134.     labor:=Nil;
  135.     outside:=Nil;
  136.     cust:=Nil;
  137.     parts:=Nil;
  138.     tools:=Nil;
  139.     jipinfo:=Nil;
  140.     invshelf:=Nil;
  141.     assembly:=Nil;
  142.     jobitems:=Nil;
  143.     invmat:=Nil;
  144.     outjobs:=Nil;
  145.     poprcdel:=Nil;
  146.     outpo:=Nil;
  147.     vendors:=Nil;
  148.     matspecs:=Nil;
  149.     porders:=Nil;
  150.     crosref:=Nil;
  151.   packets:=nil;
  152. end;
  153.  
  154. constructor JCMainRec.Create;
  155. begin
  156.     qcgang:='RUDY TOM CARLOS ';
  157.     jobs:=Nil;
  158.     due:=Nil;
  159.     ship:=Nil;
  160.     labor:=Nil;
  161.     outside:=Nil;
  162.     cust:=Nil;
  163.     parts:=Nil;
  164.     tools:=Nil;
  165.     jipinfo:=Nil;
  166.     invshelf:=Nil;
  167.     assembly:=Nil;
  168.     jobitems:=Nil;
  169.     invmat:=Nil;
  170.     outjobs:=Nil;
  171.     poprcdel:=Nil;
  172.     outpo:=Nil;
  173.     vendors:=Nil;
  174.     matspecs:=Nil;
  175.     porders:=Nil;
  176.     crosref:=Nil;
  177.   packets:=nil;
  178.   LoadDepList;
  179. end;
  180.  
  181. procedure StopJCcommon;
  182. begin
  183.   ClearFlagUse;  { at shutdown }
  184.   jcm.free;
  185. end;
  186.  
  187. function GetJStatus(jstat:integer;statdate:longint):String;
  188. begin
  189.   Result:='';
  190.   case jstat of
  191.     1: Result:='Cancelled  '+dshyph(statdate);
  192.     2: Result:='Completed  '+dshyph(statdate);
  193.     3: Result:='Closed  '+dshyph(statdate);
  194.   end;
  195. end;
  196.  
  197. procedure JCMainRec.flagstpos(job_num:string;stype:array of integer);
  198. var tt:string[60];
  199.     changlog:oDB;
  200.     ii:integer;
  201. begin
  202.   changlog:=Nil;
  203. { log when changes were made to any job info: labor,due/ship dates,costs,etc }
  204.     with jcm do begin
  205.         dbUse(changlog,compath('changlog'));
  206.         if Not empty(job_num) then begin
  207.             if changlog.Seek(job_num) then begin
  208.                 if Not changlog.aLock then begin
  209.                     dbClose(changlog);
  210.                     exit;
  211.                 End;
  212.             End Else
  213.             Begin
  214.                 changlog.Append;
  215.             End;
  216.             changlog.ss('job_no',job_num);
  217.             changlog.ss('change_1',changlog.s('change_2'));
  218.             changlog.ss('change_2',changlog.s('change_3'));
  219.             changlog.ss('change_3',changlog.s('change_4'));
  220.             changlog.ss('change_4',changlog.s('change_5'));
  221.             changlog.ss('change_5',changlog.s('mostrecent'));
  222.             tt:=datehyph(xDate)+' '+Gen.EmpNum+' ';
  223.             for ii:=1 to 11 do begin
  224.                 if stype[ii]>0 then begin
  225.                     tt:=tt+(chr(ii+64));
  226.                 End;
  227.             End;
  228.             changlog.ss('mostrecent',tt);
  229.         End;
  230.         dbClose(changlog);
  231.     end;
  232. end;
  233.  
  234.  
  235. function shortename(ename:string;lnamelen:integer):string;
  236. var tname:string[30];
  237.     start:integer;
  238. begin
  239.   if Gen.AtPDS then begin
  240.     if pos('AGIET',upper(ename))>0 then begin  { special case for Agietron }
  241.       Result:=Copy('  AGIE    ',1,lnamelen+2);
  242.     End;
  243.   End;
  244.   tname:=Copy(ename,1,1)+' ';
  245.   if pos(',',ename)>1 then begin
  246.     ename:=Copy(ename,1,pos(',',ename)-1);
  247.   End;
  248.   if pos('.',ename) = 0 then begin
  249.     start:=pos(' ',ename)+1;
  250.   End Else
  251.   Begin
  252.     start:=pos('.',ename)+2;
  253.   End;
  254.   if start=0 then begin
  255.     start := 1;
  256.   End;
  257.   tname:=tname + Copy(ename,start,lnamelen);
  258.   Result:=upper(tname);
  259. end;
  260.  
  261.  
  262. function waitcode(mwait:string):string;
  263. begin
  264.   if mwait='WFM  ' then begin
  265.     Result:='WAITING FOR MATERIAL';
  266.   end else
  267.   if mwait='WFPO ' then begin
  268.     Result:='WAITING FOR HARDCOPY P.O.';
  269.   end Else Result:=mwait;
  270. end;
  271.  
  272. function JCMainRec.croscust(pnum:string;aliasname,history,cust:oDB;
  273.   pnsrc:boolean):string;
  274. var ii,icnt,jj:integer;
  275.     res,oarea,maincnt:integer;
  276.     cnum,tseke:string[10];
  277.         harea,carea:boolean;
  278. begin
  279.     harea:=dbIsClosed(history);
  280.     if harea then dbUse(history,jcpath('history'));
  281.     carea:=dbIsClosed(cust);
  282.     if carea then dbUse(cust,compath('cust'));
  283.     icnt:=0;
  284.     maincnt:=0;  { track position of main ref. }
  285.     cnum:=space(6);
  286.     if history.Seek(pnum) then begin
  287.         While (Not history.Eof) And (history.s('part_no')=pnum) do begin
  288.             DoEvents2;
  289.             if (history.Seek(history.s('cust_no'))) And 
  290.                 (history.s('fclass')<>'*') then begin
  291.                 jj:=0;
  292.                 if icnt>0 then begin
  293.                     for ii:=1 to icnt do begin
  294.                         DoEvents2;
  295.                         if history.s('cust_no')=jcm.clist[ii] then begin
  296.                             jj:=ii;
  297.                             break;
  298.                         End;
  299.                     End;
  300.                 End;
  301.                 if (jj=0) And (icnt<40) then begin
  302.                     pp(icnt);
  303.                     jcm.clist[icnt]:=history.s('cust_no');
  304.                 End;
  305.             End;
  306.             history.Skip;
  307.         End;
  308.     End;
  309.     if aliasname.Seek(pnum) then begin
  310.         While (Not aliasname.Eof) And 
  311.             (aliasname.s('part_no')=pnum) do begin
  312.             DoEvents2;
  313.             tseke:=aliasname.s('cust_no');
  314.             if (cust.Seek(tseke)) And (cust.s('fclass')<>'*') then begin
  315.                 jj:=0;
  316.                 for ii:=1 to icnt do begin
  317.                     DoEvents2;
  318.                     if aliasname.s('cust_no')=jcm.clist[ii] then begin
  319.                         jj:=ii;
  320.                         break;
  321.                     End;
  322.                 End;
  323.                 if (jj=0) And (icnt<40) then begin
  324.                     pp(icnt);
  325.                     jj:=icnt;
  326.                     jcm.clist[icnt]:=aliasname.s('cust_no');
  327.                 End;
  328.                 if jj>0 then begin
  329.                     if aliasname.b('mainref') then begin
  330.                         maincnt:=jj;
  331.                     End;
  332.                 End;
  333.             End;
  334.             aliasname.Skip;
  335.         End;
  336.     End;
  337.     if harea then dbClose(history);
  338.     if carea then dbClose(cust);
  339.     Result:=cnum;
  340. end;
  341.  
  342.  
  343. function JCMainRec.crosload(partnum,custnum:string;crosref:oDB):boolean;
  344. var ii,oarea:integer;
  345.     crarea,bool:boolean;
  346. begin
  347.     with jcm do begin
  348.         crcnt:=0;
  349.         crosnode:=space(5);
  350.         crmainpn:=space(20);
  351.         crmaincn:=space(6);
  352.         crorgpn:=partnum;
  353.         crorgcn:=custnum;
  354.         crroot:=0;
  355.         crarea:=dbIsClosed(crosref);
  356.         if crarea then dbUse(crosref,jcpath('crosref'));
  357.         for ii:=1 to CRMAX do crpn[ii]:=space(20);
  358.         for ii:=1 to CRMAX do crcust[ii]:=space(6);
  359.         for ii:=1 to CRMAX do crmain[ii]:=False;
  360.         for ii:=1 to CRMAX do crnote[ii]:=' ';
  361.         for ii:=1 to CRMAX do crrec[ii]:=0;
  362.         if empty(custnum) then begin
  363.             custnum:=croscust(partnum,crosref,Nil,Nil,true);
  364.             crorgcn:=custnum;
  365.         End;
  366.         if crosref.Seek(partnum+custnum) then begin
  367.             crosnode:=crosref.s('node');
  368.             crosref.SetOrder(2);
  369.             crosref.Seek(crosnode);
  370.             While (Not crosref.Eof) And (crosnode=crosref.s('node')) And
  371.                     (crcnt<CRMAX) do begin
  372.                 DoEvents2;
  373.                 pp(crcnt);
  374.                 crpn[crcnt]:=crosref.s('part_no');
  375.                 crcust[crcnt]:=crosref.s('cust_no');
  376.                 crmain[crcnt]:=crosref.b('mainref');
  377.                 if crmain[crcnt] then begin
  378.                     crroot:=crcnt;
  379.                     crmainpn:=crpn[crcnt];
  380.                     crmaincn:=crcust[crcnt];
  381.                 End;
  382.                 crnote[crcnt]:=crosref.s('note');
  383.                 crrec[crcnt]:=crosref.RecNo;
  384.                 crosref.Skip;
  385.             End;
  386.             crosref.SetOrder(1);
  387.         End;
  388.         { even if no cross ref, set main pn and cust no to the orig. params }
  389.         if empty(crmainpn) then begin  { no main ref }
  390.             crmainpn:=partnum;
  391.             crmaincn:=custnum;
  392.         End;
  393.         if crarea then dbClose(crosref);
  394.         if crcnt>0 then begin
  395.             Result:=True;  { found at least one ref. }
  396.         End;
  397.         Result:=False;
  398.     end;
  399. end;
  400.  
  401.  
  402. function JCMainRec.mcrosload(partnum,custnum:string;crosmat:oDB):boolean;
  403. var ii,oarea:integer;
  404.     crarea,bool:boolean;
  405. begin
  406.     with jcm do begin
  407.         crarea:=dbIsClosed(crosmat);
  408.         if crarea then dbUse(crosmat,jcpath('crosmat'));
  409.         mcrcnt:=0;
  410.         mcrroot:=0;
  411.         mcrosnode:=space(5);
  412.         mcrmainpn:=space(20);
  413.         mcrmaincn:=space(6);
  414.         mcrorgpn:=partnum;
  415.         mcrorgcn:=custnum;
  416.         for ii:=1 to CRMAX do mcrpn[ii]:=space(20);
  417.         for ii:=1 to CRMAX do mcrcust[ii]:=space(6);
  418.         for ii:=1 to CRMAX do mcrmain[ii]:=False;
  419.         for ii:=1 to CRMAX do mcrnote[ii]:=' ';
  420.         for ii:=1 to CRMAX do mcrrec[ii]:=0;
  421.         if empty(custnum) then begin
  422.             custnum:=croscust(partnum,crosmat,Nil,Nil,false);
  423.             mcrorgcn:=custnum;
  424.         End;
  425.         if crosmat.Seek(partnum+custnum) then begin
  426.             mcrosnode:=crosmat.s('node');
  427.             crosmat.SetOrder(2);
  428.             crosmat.Seek(mcrosnode);
  429.             While (Not crosmat.eof) And
  430.               (mcrosnode=crosmat.s('node')) And
  431.                 (mcrcnt<CRMAX) do begin
  432.                 DoEvents2;
  433.                 pp(mcrcnt);
  434.                 mcrpn[mcrcnt]:=crosmat.s('part_no');
  435.                 mcrcust[mcrcnt]:=crosmat.s('cust_no');
  436.                 mcrmain[mcrcnt]:=crosmat.b('mainref');
  437.                 if mcrmain[mcrcnt] then begin
  438.                     mcrroot:=mcrcnt;
  439.                     mcrmainpn:=mcrpn[mcrcnt];
  440.                     mcrmaincn:=mcrcust[mcrcnt];
  441.                 End;
  442.                 mcrnote[mcrcnt]:=crosmat.s('note');
  443.                 mcrrec[mcrcnt]:=crosmat.RecNo;
  444.                 crosmat.Skip;
  445.             End;
  446.             crosmat.SetOrder(1);
  447.         End;
  448.         { even if no cross ref, set main pn and cust no to the orig. params }
  449.         if empty(mcrmainpn) then begin  { no main ref }
  450.             mcrmainpn:=partnum;
  451.             mcrmaincn:=custnum;
  452.         End;
  453.         if crarea then dbClose(crosmat);
  454.         if mcrcnt>0 then begin
  455.             Result:=True;  { found at least one ref. }
  456.         End;
  457.         Result:=False;
  458.     end;
  459. end;
  460.  
  461.  
  462. function JCMainRec.Endlot(curlot:string;shiftup:boolean):string;
  463. { also see oldlots() below to get old style when printing }
  464. var tparscnt,ii,level,jj,llen:integer;
  465.     tpars:array [1..10] of string135;
  466.     corejob:string[10];
  467. begin
  468.     with jcm do begin
  469.         for ii:=1 to MAXLOTS do suffixes[ii]:=' ';
  470.         tparscnt:=0;
  471.         llen:=length(curlot);
  472.         for ii:=1 to 10 do tpars[ii]:='';
  473.         corejob:=' ';
  474.         ii:=pos('-',curlot);
  475.         tpars[1]:=trim(curlot);
  476.         if ii>1 then begin  { when called from P.O. routine }
  477.             split(curlot,'-',tpars,tparscnt);
  478.             corejob:=tpars[1];
  479.             tpars[1]:=tpars[2];
  480.         End Else
  481.         Begin
  482.             if (ProcDbl(tpars[1])>0) And (length(tpars[1])>2) then begin
  483.                 corejob:=tpars[1];
  484.                 tpars[1]:='  ';
  485.             End Else
  486.             Begin
  487.                 tpars[1]:=Copy(curlot,1,2);
  488.             End;
  489.         End;
  490.         { lots are: 01-99, keep to 2 chars if possible }
  491.         suffixes[1]:='  ';
  492.         for ii:=2 to 100 do begin
  493.             DoEvents2;
  494.             if ii<11 then begin
  495.                 suffixes[ii]:='0'+transform(ii-1,'9');
  496.             End Else
  497.             Begin
  498.                 suffixes[ii]:=transform(ii-1,'99');
  499.             End;
  500.         End;
  501.         tpars[1]:=padr(tpars[1],2);
  502.         jj:=fcurlot(tpars[1]);
  503.         if shiftup then begin
  504.             pp(jj);
  505.         End Else
  506.         Begin
  507.             jj:=jj-1;
  508.         End;
  509.         if (jj>0) And (jj<=MAXLOTS) then begin
  510.             tpars[1]:=suffixes[jj];
  511.         End;
  512.         if Not empty(corejob) then begin
  513.             if Not empty(tpars[1]) then begin
  514.                 tpars[1]:=corejob+'-'+tpars[1];
  515.             End Else
  516.             Begin
  517.                 tpars[1]:=corejob;
  518.             End;
  519.         End;
  520.         if llen>length(tpars[1]) then begin
  521.             Result:=padr(tpars[1],llen);
  522.         End Else
  523.         Begin
  524.             Result:=tpars[1];
  525.         End;
  526.     end;
  527. end;
  528.  
  529.  
  530. function fcurlot(apat:string):integer;
  531. var ii,jj:integer;
  532. begin
  533.   jj:=0;
  534.   apat:=Copy(apat,1,2);
  535.   for ii:=1 to MAXLOTS do begin
  536.     if apat=jcm.suffixes[ii] then begin
  537.       jj:=ii;
  538.       break;
  539.     End;
  540.   End;
  541.   Result:=jj;
  542. end;
  543.  
  544.  
  545. function JCMainRec.oldlots(orgpo:string):string;
  546. var pc1,pc2:string[20];
  547.     ii,jj,kk,ll:integer;
  548.     ret:string[10];
  549. begin
  550.     with jcm do begin
  551.         olots[1]:=' ';
  552.         olots[2]:='A';
  553.         olots[3]:='B';
  554.         olots[4]:='C';
  555.         olots[5]:='D';
  556.         olots[6]:='E';
  557.         olots[7]:='F';
  558.         olots[8]:='G';
  559.         olots[9]:='H';
  560.         olots[10]:='J';
  561.         olots[11]:='K';
  562.         olots[12]:='L';
  563.         olots[13]:='M';
  564.         olots[14]:='N';
  565.         olots[15]:='P';
  566.         olots[16]:='Q';
  567.         olots[17]:='R';
  568.         olots[18]:='S';
  569.         olots[19]:='T';
  570.         olots[20]:='U';
  571.         olots[21]:='V';
  572.         olots[22]:='W';
  573.         olots[23]:='X';
  574.         olots[24]:='Y';
  575.         olots[25]:='Z';
  576.         olots[26]:='AA';
  577.         olots[27]:='AB';
  578.         olots[28]:='AC';
  579.         olots[29]:='AD';
  580.         olots[30]:='AE';
  581.         olots[31]:='AF';
  582.         olots[32]:='AG';
  583.         olots[33]:='AH';
  584.         olots[34]:='AJ';
  585.         olots[35]:='AK';
  586.         olots[36]:='AL';
  587.         olots[37]:='AM';
  588.         olots[38]:='AN';
  589.         olots[39]:='AP';
  590.         olots[40]:='AQ';
  591.         olots[41]:='AR';
  592.         olots[42]:='AS';
  593.         olots[43]:='AT';
  594.         olots[44]:='AU';
  595.         olots[45]:='AV';
  596.         olots[46]:='AW';
  597.         olots[47]:='AX';
  598.         olots[48]:='AY';
  599.         olots[49]:='AZ';
  600.         ll:=length(orgpo);
  601.         if empty(orgpo) then begin
  602.             Result:=orgpo;
  603.         End;
  604.         ii:=pos('-',orgpo);
  605.         ret:=orgpo;
  606.         if (length(trim(orgpo))<9) And (pos('-',orgpo)>0) then begin
  607.             jj:=fcurlot(orgpo);
  608.             if (jj>0) And (jj<51) then begin
  609.                 pc1:=Copy(orgpo,1,ii-1);
  610.                 pc2:=trim(Copy(orgpo,ii+1,6));
  611.                 if jj=2 then begin
  612.                     ret:=pc1;
  613.                 End Else
  614.                 Begin
  615.                     ret:=pc1+'-'+olots[jj-1];
  616.                 End;
  617.             End;
  618.         End;
  619.         Result:=ret;
  620.     end;
  621. end;
  622.  
  623. function oktoload(thisrec:longint;reclist:array of longint):boolean;
  624. var ii,jj:integer;
  625. begin
  626.   jj:=-1;
  627.   result:=True;
  628.   ii:=high(reclist);
  629.   for ii:=0 to high(reclist) do begin
  630.     if thisrec=reclist[ii] then begin
  631.       jj:=ii;
  632.       break;
  633.     End;
  634.   End;
  635.   if jj>=0 then begin
  636.     result:=False;
  637.   End;
  638. end;
  639.  
  640. procedure AddInv(tt:string;var InvStr:array of String135;
  641.     var atpos:integer;MaxEnts:integer);
  642. begin
  643.   if atpos<MaxEnts then begin
  644.     pp(atpos);
  645.     InvStr[atpos]:=tt;
  646.   end;
  647. end;
  648.  
  649. procedure JobRec.runbal(rettot:double;
  650.   var InvStr:array of string135;var atpos:integer;maxents:integer);
  651. var ii,mm,kk,yy,jj,xx:integer;
  652.         bool:boolean;
  653.     tdue,tship,duesum:double;
  654.     inventor:oDB;
  655.         jlist,jfnd:TStringList;
  656.     tt:string;
  657.         dlist:array [0..100] of longint;
  658.         qlist,jbal:array [0..100] of double;
  659. begin
  660.   inventor:=Nil;
  661.   jlist:=Tstringlist.create;
  662.   jfnd:=Tstringlist.create;
  663.   dbUse(inventor,jcpath('inventor'));
  664.   if empty(custnum) then begin
  665.     if inventor.Seek(partnum) then begin
  666.       custnum:=inventor.s('cust_no');
  667.     End;
  668.   End;
  669.   jcm.crosload(partnum,custnum,nil);
  670.   { check to see if part and cust valid entries, even if they may }
  671.   { not be main refs. in some situations }
  672.   if (parts.Seek(jcm.crmainpn)) And (cust.Seek(jcm.crmaincn)) And
  673.     (Not empty(jcm.crmaincn)) then begin
  674.     if Not inventor.Seek(jcm.crmainpn+jcm.crmaincn) then begin
  675.       inventor.Append;
  676.       inventor.ss('part_no',jcm.crmainpn);
  677.       inventor.ss('cust_no',jcm.crmaincn);
  678.       inventor.ss('div_no','1 ');
  679.       inventor.unLock;
  680.     End;
  681.   End;
  682.   inventor.Seek(jcm.crmainpn+jcm.crmaincn);
  683.   { now load due date list }
  684.   if jcm.crcnt=0 then begin
  685.     jcm.crcnt:=1;
  686.     jcm.crpn[1]:=jcm.crmainpn;
  687.     jcm.crcust[1]:=jcm.crmaincn;
  688.   End;
  689.   jobs.setorder(2);
  690.   for ii:=1 to jcm.crcnt do begin
  691.     if jobs.Seek(jcm.crpn[ii]) then begin
  692.       bool:=False;
  693.       { check to see if part already done }
  694.       if ii>1 then begin
  695.         for kk:=1 to ii-1 do begin
  696.           if jcm.crpn[kk]=jcm.crpn[ii] then begin
  697.             bool:=True;
  698.             break;
  699.           End;
  700.         End;
  701.       End;
  702.       if Not bool then begin  { haven't calculated for this part yet }
  703.         While (Not jobs.Eof) And
  704.                   (jcm.crpn[ii]=jobs.s('part_no')) do begin
  705.           if jobs.f('jstatus')=0 then begin
  706.             tship:=0;
  707.             if ship.Seek(jobs.s('job_no')) then begin
  708.               While (Not ship.Eof) And
  709.                               (jobs.s('job_no')=ship.s('job_no')) do begin
  710.                 tship:=tship+(ship.f('qty'));
  711.                 ship.Skip;
  712.               End;
  713.             End;
  714.             mm:=-1;
  715.             if jfnd.count>0 then begin
  716.               for jj:=0 to jfnd.count-1 do begin
  717.                 if jobs.s('job_no')=jfnd[jj] then begin
  718.                   mm:=jj;
  719.                   break;
  720.                 End;
  721.               End;
  722.             End;
  723.             if mm<0 then begin
  724.                           jfnd.add(jobs.s('job_no')+
  725.                               transform(jobs.f('qty')-tship,'99999999'));
  726.               tdue:=0;
  727.               if due.Seek(jobs.s('job_no')) then begin
  728.                 While (Not due.Eof) And
  729.                   (jobs.s('job_no')=due.s('job_no'))
  730.                   do begin
  731.                   tdue:=tdue+(due.f('qty'));
  732.                   { go out 1 yr. }
  733.                   if (tdue>tship) And
  734.                     ((due.d('fdate')<=(datemath(xDate,380))) or
  735.                                         (due.d('fdate')>=ctod('01/01/99')))
  736.                     then begin
  737.                     jlist.add(dtos(due.d('fdate'))+
  738.                       due.s('job_no')+
  739.                       transform(due.f('qty'),'99999999'));
  740.                   End;
  741.                   due.Skip;
  742.                 End;
  743.               end;
  744.             End;
  745.           End;
  746.           jobs.Skip;
  747.         End;
  748.       End;
  749.     End;
  750.   End;
  751.   if jlist.count>0 then begin
  752.     { sort individual entries }
  753.     jlist.sort;
  754.     for ii:=0 to jlist.count-1 do begin
  755.       { these items must be in this order of assignment
  756.         because dlist and qlist need jlist before jlist is changed }
  757.       dlist[ii]:=stod(Copy(jlist[ii],1,8));
  758.       qlist[ii]:=ProcDbl(Copy(jlist[ii],19,8));
  759.       jlist[ii]:=Copy(jlist[ii],9,10);
  760.     End;
  761.     { sort job totals }
  762.   End;
  763.   if jfnd.count>0 then begin
  764.     jfnd.sort;
  765.     for ii:=0 to jfnd.count-1 do begin
  766.       jbal[ii]:=ProcDbl(Copy(jfnd[ii],11,8));
  767.       jfnd[ii]:=Copy(jfnd[ii],1,10);
  768.     End;
  769.   End;
  770.   addinv('',invstr,atpos,maxents);
  771.   addinv(space(14)+'DELIVERY REQUIREMENTS',invstr,atpos,maxents);
  772.   addinv('',invstr,atpos,maxents);
  773.   tt:=space(11)+'Current:  '+transform(rettot,'99,999,999')+
  774.       '    Balance';
  775.   addinv(tt,invstr,atpos,maxents);
  776.   duesum:=0;
  777.   for ii:=0 to jlist.count-1 do begin
  778.     tt:='  '+copy(jlist[ii],1,8)+dshyph(dlist[ii])+
  779.         '   '+transform(qlist[ii],'99,999,999');
  780.     duesum:=duesum+(qlist[ii]);
  781.     tt:=tt+'  '+transform(rettot-duesum,'99,999,999');
  782.       addinv(tt,invstr,atpos,maxents);
  783.   End;
  784.   addinv('',invstr,atpos,maxents);
  785.   tt:=space(16)+'TOTAL BAL. DUE';
  786.   addinv(tt,invstr,atpos,maxents);
  787.   addinv('',invstr,atpos,maxents);
  788.   tdue:=0;
  789.   for ii:=0 to jfnd.count-1 do begin
  790.     tt:=space(9)+jfnd[ii]+'  '+transform(jbal[ii],'99,999,999');
  791.       addinv(tt,invstr,atpos,maxents);
  792.     tdue:=tdue+(jbal[ii]);
  793.   end;
  794.   addinv('',invstr,atpos,maxents);
  795.   tt:=space(15)+'TOTAL '+transform(tdue,'99,999,999');
  796.   addinv(tt,invstr,atpos,maxents);
  797.   jobs.setorder(1);
  798.   dbClose(inventor);
  799.   pp(atpos);  { add when so it is correct after returning }
  800.      jlist.free;
  801.      jfnd.free;
  802. end;
  803.  
  804. procedure JobRec.LoadInv(var totdone,totless:longint;
  805.   var InvStr:array of string135;var invcnt:integer);
  806. var curarea,maxents,ii,jj,kk,rcnt:integer;
  807.         tcustname,tt,tt2,tt3:string135;
  808.     t1,t2,t3,tdone,tless:longint;
  809.         rlist:array [1..50] of longint;
  810.         hcnt,seln:integer;
  811.         ojarea,ojdone,oparea,ovarea,oim:boolean;
  812.     lastpo:string[20];
  813.         tpounds,tcount:double;
  814.         lastin:longint;
  815. begin
  816.     oim:=dbIsClosed(invmat);
  817.     ojarea:=dbIsClosed(outjobs);
  818.     ojdone:=dbIsClosed(poprcdel);
  819.     oparea:=dbIsClosed(outpo);
  820.     ovarea:=dbIsClosed(vendors);
  821.     if oim then dbUse(invmat,jcpath('invmat'));
  822.     if ojarea then dbUse(outjobs,jcpath('outjobs'));
  823.     if ojdone then dbUse(poprcdel,jcpath('poprcdel'));
  824.     if ovarea then dbUse(vendors,compath('vendors'));
  825.     if oparea then begin
  826.       dbUse(outpo,jcpath('outpo'));
  827.         outpo.SetOrder(2);
  828.     End;
  829.   maxents:=high(InvStr);
  830.   invcnt:=-1;
  831.   for ii:=1 to 50 do rlist[ii]:=0;
  832.   for ii:=0 to maxents do invstr[ii]:='';
  833.   if not empty(jobnum) then begin
  834.     jcm.crosload(partnum,custnum,nil);
  835.     cust.Seek(custnum);
  836.     tcustname:=upper(cust.s('name'));
  837.     if jcm.crcnt=0 then begin
  838.       jcm.crcnt:=1;
  839.       jcm.crpn[1]:=partnum;
  840.       jcm.crcust[1]:=custnum;
  841.     End;
  842.     tt:=tcustname;
  843.     tt2:=custnum;
  844.     tt3:='';
  845.     crosgroup(True,tt,tt2,tt3);
  846.     if tt2<>custnum then begin
  847.       pp(jcm.crcnt);
  848.       jcm.crpn[jcm.crcnt]:=partnum;
  849.       jcm.crcust[jcm.crcnt]:=tt2;
  850.     End;
  851.     totdone:=0;
  852.     totless:=0;
  853.     invcnt:= -1; { string array is zero based }
  854.     rcnt:=0;
  855.     for ii:=1 to jcm.crcnt do begin
  856.       if invshelf.Seek(jcm.crpn[ii]+jcm.crcust[ii]) then begin
  857.         While (Not invshelf.Eof) And
  858.                   (jcm.crpn[ii]=invshelf.s('part_no'))
  859.           And (jcm.crcust[ii]=invshelf.s('cust_no')) do begin
  860.           { only load data when adjusting }
  861.           tt:='';
  862.                     DoEvents2;
  863.           if invcnt<maxents then begin
  864.                         { this record hasn't been loaded yet }
  865.             if oktoload(invshelf.RecNo,rlist) then begin
  866.               pp(rcnt);
  867.               rlist[rcnt]:=invshelf.RecNo;
  868.               invcnt:=invcnt+1;
  869.               tdone:=0;
  870.               tless:=0;
  871.                             t1:=invshelf.l('donecnt');
  872.                             t2:=invshelf.l('doneat');
  873.                             t3:=invshelf.l('doneodd');
  874.               if not invshelf.b('incomplete') then begin
  875.                 tdone:=(t1*t2)+t3;
  876.               end else begin
  877.                 tless:=(t1*t2)+t3;
  878.               end;
  879.               totless:=totless+tless;
  880.               totdone:=totdone+tdone;
  881.               tt:='';
  882.               tt:=tt+invshelf.st('part_no');
  883.               if not empty(invshelf.st('rev_no')) then
  884.                 tt:=tt+' '''+invshelf.st('rev_no')+'''';
  885.               tt:=padr(tt,17);
  886.               tt:=tt+' S.O. '+invshelf.sn('lot_no',7);
  887.               tt:=tt+' Loc. '+Copy(invshelf.s('location'),1,3);
  888.               tt:=tt+' Inv# '+ltrim(invshelf.s('inv_no'));
  889.                     addinv(tt,invstr,invcnt,maxents);
  890.               if tdone>0 then
  891.                 tt:='   '+ltrim(ltransform(tdone,'99,999,999'))+
  892.                   ' Complete'
  893.               else
  894.                 tt:='   '+ltrim(ltransform(tless,'99,999,999'))+
  895.                   ' Incomplete';
  896.                             tt:=tt+'  Updated '+
  897.                               datehyph(invshelf.d('lastupdate'));
  898.                  addinv(tt,invstr,invcnt,maxents);
  899.                             tt:=invshelf.st('comment1')+
  900.                               invshelf.st('comment2');
  901.                             if not empty(tt) then begin
  902.                    addinv('   '+tt,invstr,invcnt,maxents);
  903.                             end;
  904.             end;
  905.           End;
  906.           invshelf.Skip;
  907.         End;
  908.       End;
  909.             if assembly.Seek(jcm.crpn[ii]) then begin
  910.                 While (Not assembly.Eof) And
  911.                   (jcm.crpn[ii]=assembly.s('assy_no')) do begin
  912.                     if (invshelf.Seek(assembly.s('part_no'))) then begin
  913.                         While (Not invshelf.Eof) And
  914.                         (invshelf.s('part_no')=assembly.s('part_no'))
  915.                         do begin
  916.                             if (invcnt<maxents) and
  917.                                     (oktoload(invshelf.RecNo,rlist)) then begin
  918.                                 rcnt:=rcnt+1;
  919.                                 rlist[rcnt]:=invshelf.RecNo;
  920.                                 invcnt:=invcnt+1;
  921.                                 tdone:=0;
  922.                                 tless:=0;
  923.                                 t1:=invshelf.l('donecnt');
  924.                                 t2:=invshelf.l('doneat');
  925.                                 t3:=invshelf.l('doneodd');
  926.                                 if not invshelf.b('incomplete') then begin
  927.                                     tdone:=(t1*t2)+t3;
  928.                                 end else begin
  929.                                     tless:=(t1*t2)+t3;
  930.                                 end;
  931.                                 totless:=totless+tless;
  932.                                 totdone:=totdone+tdone;
  933.                                 tt:='';
  934.                                 tt:=tt+invshelf.st('part_no');
  935.                                 if not empty(invshelf.st('rev_no')) then
  936.                                     tt:=tt+' '''+invshelf.st('rev_no')+'''';
  937.                                 tt:=padr(tt,17);
  938.                                 tt:=tt+' S.O. '+invshelf.sn('lot_no',7);
  939.                                 tt:=tt+' Loc. '+Copy(invshelf.s('location'),1,3);
  940.                                 tt:=tt+' Inv# '+ltrim(invshelf.s('inv_no'));
  941.                      addinv(tt,invstr,invcnt,maxents);
  942.                                 if tdone>0 then
  943.                                     tt:='   '+ltrim(ltransform(tdone,'99,999,999'))+
  944.                                         ' Complete'
  945.                                 else
  946.                                     tt:='   '+ltrim(ltransform(tless,'99,999,999'))+
  947.                                         ' Incomplete';
  948.                                 tt:=tt+'  Updated '+
  949.                                     datehyph(invshelf.d('lastupdate'));
  950.                   addinv(tt,invstr,invcnt,maxents);
  951.                                 tt:=assembly.st('assy_no');
  952.                 tt2:=assembly.st('part_no');
  953.                                 if (invcnt<maxents) and (tt<>tt2) then begin
  954.                                     tt:='   '+assembly.st('name')+
  955.                                       ' Of '+tt;
  956.                       addinv(tt,invstr,invcnt,maxents);
  957.                                 end;
  958.                                 tt:=invshelf.st('comment1')+
  959.                                   invshelf.st('comment2');
  960.                                 if not empty(tt) then begin
  961.                       addinv('   '+tt,invstr,invcnt,maxents);
  962.                                 end;
  963.                             end;
  964.                             invshelf.Skip;
  965.                         End;
  966.                     End;
  967.                     assembly.Skip;
  968.                 End;
  969.             end;
  970.     End;
  971.         { load running balance }
  972.         RunBal(totdone,InvStr,invcnt,maxents);
  973.     if invmat.Seek(trim(jobnum)) then begin
  974.          addinv('',invstr,invcnt,maxents);
  975.       addinv(space(14)+'MATERIAL INVENTORY',invstr,invcnt,maxents);
  976.          addinv('',invstr,invcnt,maxents);
  977.       while (not invmat.Eof) and (trim(jobnum)=invmat.st('lot_no')) do begin
  978.                 DoEvents2;
  979.         tt:='Lot '+invmat.sn('lot_no',9);
  980.         tt:=tt+
  981.           transform(invmat.f('lbs_mat'),'99,999')+' Lbs.,  Loc. ';
  982.         tt:=tt+
  983.           invmat.sn('location',3)+' Inv #'+invmat.st('inv_no');
  984.              addinv(tt,invstr,invcnt,maxents);
  985.         invmat.Skip;
  986.       end;
  987.     end;
  988.        addinv('',invstr,invcnt,maxents);
  989.     addinv(space(12)+'OUTSIDE PROCESSING LIST',invstr,invcnt,maxents);
  990.        addinv('',invstr,invcnt,maxents);
  991.     addinv('Shipped'+space(10)+'Out/Do Back'+space(2)+'Lbs.',
  992.       invstr,invcnt,maxents);
  993.     if outjobs.Seek(jobnum) then begin
  994.       lastpo:=' ';
  995.       hcnt:=0;
  996.       While (Not outjobs.Eof) And
  997.         (outjobs.s('job_no')=jobnum) do begin
  998.                 DoEvents2;
  999.         if (outjobs.d('received')=0) And
  1000.           (outjobs.d('fdate')>=(DateMath(xDate,-35))) then begin
  1001.           if lastpo<>outjobs.s('po_no') then begin
  1002.             hcnt:=hcnt+1;
  1003.           End;
  1004.           outpo.Seek(outjobs.s('out_no'));
  1005.           tpounds:=0;
  1006.           tcount:=0;
  1007.           lastin:=ctod(' ');
  1008.           if poprcdel.Seek(outjobs.s('po_no')) then begin
  1009.             While (Not poprcdel.Eof) And
  1010.               (poprcdel.s('po_no')=outjobs.s('po_no')) do begin
  1011.                             DoEvents2;
  1012.               lastin:=poprcdel.d('dtreceived');
  1013.               tpounds:=tpounds+(poprcdel.f('pounds'));
  1014.               tcount:=tcount+(poprcdel.f('count'));
  1015.               poprcdel.Skip;
  1016.             End;
  1017.           End;
  1018.           jobs.Seek(outjobs.s('job_no'));
  1019.           vendors.Seek(outpo.s('for_vend'));
  1020.           cust.Seek(jobs.s('cust_no'));
  1021.           tt:=Copy(outjobs.s('po_no'),1,8)+' '+
  1022.             Copy(upper(vendors.s('name')),1,5)+'  '+
  1023.             copy(datehyph(outjobs.d('fdate')),1,5)+'  '+
  1024.             copy(datehyph(outjobs.d('dtrequired')),1,5);
  1025.           if outpo.f('poundcode')<>1 then begin
  1026.             tt:=tt+
  1027.               transform(outjobs.f('pounds')-tpounds,'999999');
  1028.             if outjobs.f('count')>0 then
  1029.               tt:=tt+
  1030.                   transform(outjobs.f('count')-tcount,'99,999,999')+
  1031.                 ' PCS.';
  1032.                          addinv(tt,invstr,invcnt,maxents);
  1033.           End Else
  1034.           Begin
  1035.             tt:=tt+
  1036.               transform(outjobs.f('pounds')-tpounds,'9,999,999');
  1037.                      addinv(tt,invstr,invcnt,maxents);
  1038.           End;
  1039.           lastpo:=outjobs.s('po_no');
  1040.         End;
  1041.         outjobs.Skip;
  1042.       End;
  1043.     End;
  1044.     if hcnt=0 then begin
  1045.          addinv('',invstr,invcnt,maxents);
  1046.       addinv(space(10)+'No Outstanding Processing',invstr,invcnt,maxents);
  1047.     End;
  1048.     if oim then dbClose(invmat);
  1049.     if ojarea then dbClose(outjobs);
  1050.     if ojdone then dbClose(poprcdel);
  1051.     if oparea then dbClose(outpo);
  1052.     if ovarea then dbClose(vendors);
  1053.   end;
  1054. End;
  1055.  
  1056. procedure JobRec.ldmspec(var rtt,rtt2:string);
  1057. var ii,seln:integer;
  1058.     omat,opord,ovend:boolean;
  1059. begin
  1060.     rtt:=space(35);
  1061.     rtt2:=space(35);
  1062.     omat:=dbIsClosed(matspecs);
  1063.     opord:=dbIsClosed(porders);
  1064.     ovend:=dbIsClosed(vendors);
  1065.     if omat then dbUse(matspecs,jcpath('matspecs'));
  1066.     if opord then dbUse(porders,jcpath('porders'));
  1067.   if ovend then dbUse(vendors,compath('vendors'));
  1068.     if porders.Seek(trim(jobnum)) then begin
  1069.         rtt:='';
  1070.         if vendors.Seek(porders.s('vendor_no')) then begin
  1071.             split(vendors.s('name'),' ',pars,parscnt);
  1072.             rtt:=pars[1]+' ';
  1073.             if parscnt>1 then begin
  1074.                 rtt:=rtt+pars[2];
  1075.             End;
  1076.             rtt:=rtt+', ';
  1077.         End;
  1078.         if matspecs.Seek(porders.s('part_no')) then begin
  1079.             rtt:=rtt+trim(matspecs.s('mattype'));
  1080.             split(matspecs.s('size_req'),' ',pars,parscnt);
  1081.             rtt2:=trim(porders.s('qty'))+' '+pars[1];
  1082.             for ii:=1 to parscnt-1 do begin
  1083.                 if pars[ii]='X' then begin
  1084.                     rtt2:=rtt2+'x'+pars[ii+1];
  1085.                 End;
  1086.             End;
  1087.             rtt2:=rtt2+'  DUE '+
  1088.               ltrim(Copy(datehyph(porders.d('dtrequired')),1,5));
  1089.         End;
  1090.     End Else
  1091.     Begin
  1092.         if jipinfo.Seek(jobnum) then begin
  1093.             rtt:=jipinfo.s('mat1');
  1094.             rtt2:=jipinfo.s('mat2');
  1095.         End;
  1096.     End;
  1097.     if omat then dbClose(matspecs);
  1098.     if opord then dbClose(porders);
  1099.     if ovend then dbClose(vendors);
  1100. end;
  1101.  
  1102.  
  1103. procedure JobRec.chkrevno(forpn:string);
  1104. var tt:string;
  1105. begin
  1106.   if parts.Seek(forpn) then begin
  1107.     if (parts.s('rev_mot') <> parts.s('lrev_mot')) Or
  1108.       (parts.s('lmot_date') <> parts.s('mot_date'))
  1109.             then begin
  1110.       tt:='Rev Change: P/N '+trim(forpn);
  1111.       tt:=tt+' Current Rev: '+parts.s('rev_mot')+' Was '+
  1112.         trim(parts.s('lrev_mot'));
  1113.       tt:=tt+' Current MOT: '+datehyph(parts.d('mot_date'))+' Was '+
  1114.         datehyph(parts.d('lmot_date'));
  1115.       if Gen.User='CARL ' then begin
  1116.               if YesNoBox(tt) then begin
  1117.                     if parts.aLock then begin
  1118.                         parts.ss('lrev_mot',parts.s('rev_mot'));
  1119.                         parts.dd('lmot_date',parts.d('mot_date'));
  1120.                         parts.dd('lastchange',xDate);
  1121.                         parts.unLock;
  1122.                     End Else
  1123.                     Begin
  1124.                         OKbox('Unable To Save Change - Try Again Later');
  1125.                     End;
  1126.                 end;
  1127.       End;
  1128.     End;
  1129.   End;
  1130. End;
  1131.  
  1132. function JobRec.Load(jbnum:string;WithLock:boolean):boolean;
  1133. var ii,jj:integer;
  1134.     fother,tup,dollar,tax:string[30];
  1135.         tup2:double;
  1136. begin
  1137.     jobnum:='';
  1138.     revnum:='';
  1139.     orevnum:='';
  1140.     partnum:='';
  1141.     partname:='';
  1142.     custnum:='';
  1143.     shipnum:='';
  1144.     custname:='';
  1145.     buyer:='';
  1146.     depname:='';
  1147.     ponum:='';
  1148.     oponum:='';
  1149.     motdate:=0;
  1150.     omotdate:=0;
  1151.     jstatus:=0;
  1152.     ojstatus:=0;
  1153.     statdate:=0;
  1154.     qty:=0.00;
  1155.     uprice:=0.00;
  1156.     ouprice:=0.00;
  1157.     addon:=0.00;
  1158.   jobchg:=false;
  1159.     duechg:=false;
  1160.     shipchg:=false;
  1161.     jipchg:=false;
  1162.     itemschg:=false;
  1163.     SaveData:=false;
  1164.     scnt:=0;
  1165.     dcnt:=0;
  1166.     ocnt:=0;
  1167.     oscnt:=0;
  1168.     tcnt:=0;
  1169.     StillDue:=0;
  1170.     recnum:=0;
  1171.     islocked:=false;
  1172.   tobpless:='';
  1173.   billnum:='';
  1174.   lineitem:='';
  1175.   orgqty:=0;
  1176.   note1:='';
  1177.   note2:='';
  1178.   note3:='';
  1179.   taxable:=false;
  1180.   ourmat:=true;
  1181.   tobp:=true;
  1182.     barfai:='';
  1183.     waitstatus:='';
  1184.     clozapprov:='';
  1185.     lotmadeto:='';
  1186.     lotinspto:='';
  1187.     lotshipto:='';
  1188.     mater_est:=0;
  1189.     proc_est:=0;
  1190.     labor_est:=0;
  1191.     bid:=0;
  1192.     complete:=0;
  1193.     partial:=0;
  1194.     material:=0;
  1195.     matsel:=0;
  1196.     procsel:=0;
  1197.     setupdate:=0;
  1198.     porecdate:=0;
  1199.     lastchange:=0;
  1200.     invless:='';
  1201.   for ii:=1 to 3 do begin
  1202.     specitem[ii]:='';
  1203.     speccom[ii]:='';
  1204.     specup[ii]:=0;
  1205.     specper[ii]:='';
  1206.   end;
  1207.   for ii:=1 to 5 do ttrems[ii]:='';
  1208.     mat1:='';
  1209.     mat2:='';
  1210.     for ii:=1 to MaxDue do begin
  1211.         DoEvents2;
  1212.         dqty[ii]:=0;
  1213.         ddates[ii]:=0;
  1214.         dstat[ii]:=0;
  1215.         drecs[ii]:=0;
  1216.         odqty[ii]:=0;
  1217.         odates[ii]:=0;
  1218.         srecs[ii]:=0;
  1219.         sqty[ii]:=0;
  1220.         sdates[ii]:=0;
  1221.         sinv[ii]:=0;
  1222.         slot[ii]:='   ';
  1223.         svia[ii]:='   ';
  1224.         sshippr[ii]:=space(12);
  1225.     end;
  1226.     for ii:=1 to MaxTools do begin
  1227.         toolsa[ii]:='';
  1228.     end;
  1229.     jobnum:=padr(jbnum,10);
  1230.     if not empty(jobnum) then begin
  1231.         jobs.SetOrder(1);
  1232.         if jobs.Seek(jobnum) then begin
  1233.             recnum:=jobs.RecNo;
  1234.           if withlock then begin
  1235.                 if jobs.aLock then begin
  1236.                     islocked:=true;
  1237.                     FlagOn(jobnum,'J');
  1238.                 end;
  1239.             end;
  1240.             revnum:=jobs.s('rev_no');
  1241.             joblink:=jobs.s('joblink');
  1242.             custref:=jobs.s('cust_ref');
  1243.             orderdate:=jobs.d('orderdate');
  1244.             orevnum:=revnum;
  1245.             partnum:=jobs.s('part_no');
  1246.             if parts.Seek(partnum) then partname:=parts.s('name');
  1247.             custnum:=jobs.s('cust_no');
  1248.             shipnum:=jobs.s('ship_no');
  1249.             billnum:=jobs.s('bill_to');
  1250.       lineitem:=jobs.s('line_item');
  1251.             if cust.Seek(custnum) then custname:=cust.s('name');
  1252.             if jipinfo.Seek(jobnum) then begin
  1253.         buyer:=jipinfo.st('buyer');
  1254.         tobp:=jipinfo.b('tobp');
  1255.         tobpless:=jipinfo.s('less');
  1256.         ttrems[1]:=jipinfo.s('rem1');
  1257.         ttrems[2]:=jipinfo.s('rem2');
  1258.         ttrems[3]:=jipinfo.s('rem3');
  1259.         ttrems[4]:=jipinfo.s('rem4');
  1260.         ttrems[5]:=jipinfo.s('rem5');
  1261.                 mat1:=jipinfo.s('mat1');
  1262.                 mat2:=jipinfo.s('mat2');
  1263.       end;
  1264.             depname:=GetDept(jobs.s('dep'));
  1265.             depnum:=jobs.s('dep');
  1266.             ponum:=jobs.s('po_no');
  1267.             oponum:=ponum;
  1268.             qty:=jobs.n('qty');
  1269.       orgqty:=jobs.f('org_qty');
  1270.             oqty:=qty;
  1271.             uprice:=jobs.n('unit_price');
  1272.             ouprice:=uprice;
  1273.             motdate:=jobs.d('mot_date');
  1274.             omotdate:=motdate;
  1275.             jstatus:=jobs.i('jstatus');
  1276.             ojstatus:=jstatus;
  1277.             statdate:=jobs.d('statdate');
  1278.             ostatdate:=statdate;
  1279.         taxable:=jobs.b('taxable');
  1280.         ourmat:=empty(jobs.s('ourmat'));
  1281.             barfai:=jobs.s('bar_fai');
  1282.             waitstatus:=jobs.s('waitstatus');
  1283.             clozapprov:=jobs.s('clozapprov');
  1284.             lotmadeto:=jobs.s('lotmadeto');
  1285.             lotinspto:=jobs.s('lotinspto');
  1286.             lotshipto:=jobs.s('lotshipto');
  1287.             mater_est:=jobs.f('mater_est');
  1288.             proc_est:=jobs.f('proc_est');
  1289.             labor_est:=jobs.f('labor_est');
  1290.             bid:=jobs.f('bid');
  1291.             complete:=jobs.f('complete');
  1292.             partial:=jobs.f('partial');
  1293.             material:=jobs.f('material');
  1294.             matsel:=jobs.i('matsel');
  1295.             procsel:=jobs.i('procsel');
  1296.             setupdate:=jobs.d('setupdate');
  1297.             porecdate:=jobs.d('porecdate');
  1298.             lastchange:=jobs.d('lastchange');
  1299.             invless:=jobs.s('less');
  1300.             if dbIsOpen(tools) then begin
  1301.                 tools.SetOrder(2);
  1302.                 if tools.Seek(partnum) then begin
  1303.                     while (not tools.Eof) and (partnum=tools.s('part_no')) and
  1304.                         (tcnt<MaxTools)
  1305.                     do begin
  1306.                         DoEvents2;
  1307.                         tcnt:=tcnt+1;
  1308.                         toolsa[tcnt]:=tools.sn('tool_no',10)+' '+tools.sn('name',20);
  1309.                         tools.Skip;
  1310.                     end;
  1311.                 end;
  1312.             end;
  1313.             totdue:=0;
  1314.             totship:=0;
  1315.             if ship.Seek(jobnum) then begin
  1316.                 while (not ship.Eof) and (jobnum=ship.s('job_no')) and
  1317.                     (scnt<MaxDue) do begin
  1318.                     DoEvents2;
  1319.                     scnt:=scnt+1;
  1320.                     jj:=pos('-',ship.s('shipper_no'));
  1321.                     if jj>0 then slot[scnt]:=copy(ship.s('shipper_no'),jj+1,3);
  1322.                     sdates[scnt]:=ship.d('fdate');
  1323.                     sqty[scnt]:=ship.f('qty');
  1324.                     srecs[scnt]:=ship.RecNo;
  1325.                     totship:=totship+sqty[scnt];
  1326.                     sinv[scnt]:=ship.d('inv_date');
  1327.                     svia[scnt]:=ship.s('ship_via');
  1328.                     sshippr[scnt]:=ship.s('shipper_no');
  1329.                     ship.Skip;
  1330.                 end;
  1331.             end;
  1332.             if due.Seek(jobnum) then begin
  1333.                 while (not due.Eof) and (jobnum=due.s('job_no')) and
  1334.                         (dcnt<MaxDue) do begin
  1335.                     DoEvents2;
  1336.                     dcnt:=dcnt+1;
  1337.                     ocnt:=dcnt;
  1338.                     dqty[dcnt]:=due.f('qty');
  1339.                     odqty[dcnt]:=dqty[dcnt];
  1340.                     drecs[dcnt]:=due.RecNo;
  1341.                     totdue:=totdue+dqty[dcnt];
  1342.                     if (totdue>totship) and (StillDue=0) then StillDue:=dcnt;
  1343.                     ddates[dcnt]:=due.d('fdate');
  1344.                     odates[dcnt]:=ddates[dcnt];
  1345.                     due.Skip;
  1346.                 end;
  1347.             end;
  1348.         end;
  1349.         otherup:=0;
  1350.         otherchgs:=0;
  1351.         othertext:='';
  1352.         if jobitems.Seek(jobnum) then begin
  1353.       ii:=0;
  1354.             While (Not jobitems.Eof) And (jobitems.s('job_no')=jobnum) do begin
  1355.                 DoEvents2;
  1356.                 if (pos('L',jobitems.s('itype'))>0) Or
  1357.                     (pos('1',jobitems.s('itype'))>0) then begin  { lot charge }
  1358.                     otherchgs:=otherchgs+(jobitems.f('unit_price'));
  1359.                     if Gen.CanSeePrice then begin
  1360.                         othertext:=othertext+trim(jobitems.s('descrip'))+' ($'+
  1361.                             ltrim(transform(jobitems.f('unit_price'),
  1362.                                 '999,999.99'))+')';
  1363.                     End Else
  1364.                     Begin
  1365.                         othertext:=othertext+trim(jobitems.s('descrip'));
  1366.                     End;
  1367.                 End Else
  1368.                 Begin
  1369.                     otherup:=otherup+(jobitems.f('unit_price'));
  1370.                 End;
  1371.         ii:=ii+1;
  1372.         if ii<4 then begin
  1373.                 specitem[ii]:=jobitems.s('item');
  1374.                 speccom[ii]:=jobitems.s('descrip');
  1375.                 specup[ii]:=jobitems.f('unit_price');
  1376.                 specper[ii]:=jobitems.s('itype');
  1377.         end;
  1378.                 jobitems.Skip;
  1379.             End;
  1380.         End;
  1381.         dollar:='';
  1382.         fother:='';
  1383.         tax:='';
  1384.         if taxable then begin
  1385.             tax:='+Tax ';
  1386.         End;
  1387.         if Gen.AtPDS then begin
  1388.             if Gen.CanSeePrice then begin  { can see prices }
  1389.                 if jobs.f('unit_price')<0 then begin
  1390.                     dollar:='   @ $'+
  1391.                     ltrim(transform(abs(jobs.f('unit_price')),'999,999.99'))+
  1392.                         '/Lot';
  1393.                 End Else
  1394.                 Begin
  1395.                     if jobs.f('unit_price')>0 then begin
  1396.                         if jobs.f('unit_price')>2 then begin
  1397.                             dollar:='   @ $'+
  1398.                                 ltrim(transform(jobs.f('unit_price'),'999,999.99'));
  1399.                         End Else
  1400.                         Begin
  1401.                             dollar:='   @ $'+
  1402.                                 ltrim(transform(jobs.f('unit_price'),'9,999.9999'));
  1403.                         End;
  1404.                     End Else
  1405.                     Begin
  1406.                         if Not empty(tax) then begin
  1407.                             dollar:='   @ $0.00';
  1408.                         End;
  1409.                     End;
  1410.                 End;
  1411.             End;
  1412.         End Else
  1413.         Begin
  1414.             tup:=ltrim(transform(jobs.f('unit_price')+otherup,'999,999.9999'));
  1415.             tup2:=ProcDbl(Copy(tup,length(tup)-1,2));
  1416.             if Gen.CanSeePrice then begin
  1417.                 if tup2>0 then begin
  1418.                     dollar:='    @ $'+
  1419.                         ltrim(transform(jobs.f('unit_price')+
  1420.                         otherup,'999,999.9999'));
  1421.                 End Else
  1422.                 Begin
  1423.                     dollar:='    @ $'+
  1424.                         ltrim(transform(jobs.f('unit_price')+
  1425.                         otherup,'999,999.99'));
  1426.                 End;
  1427.             End;
  1428.         End;
  1429.         tup:='';
  1430.         if (otherchgs>0) Or (otherup>0) then begin
  1431.             if otherup>0 then begin
  1432.                 if otherup>2 then begin
  1433.                     tup:='+'+ltrim(transform(otherup,'999,999.99'));
  1434.                 End Else
  1435.                 Begin
  1436.                     tup:='+'+ltrim(transform(otherup,'999.9999'));
  1437.                 End;
  1438.             End;
  1439.             if otherchgs>0 then begin
  1440.                 if Not empty(dollar) then begin
  1441.                     fother:='+'+ltrim(transform(otherchgs,'99,999.99'));
  1442.                 End Else
  1443.                 Begin
  1444.                     fother:=' @ $0.00+'+ltrim(transform(otherchgs,'99,999.99'));
  1445.                 End;
  1446.             End;
  1447.         End;
  1448.         uptext:=dollar+tup+fother+tax;
  1449.     end;
  1450.   result:=islocked;
  1451. end;
  1452.  
  1453. procedure JobRec.Save;
  1454. var jobrecs:array [1..3] of longint;
  1455.     ii,jj:integer;
  1456. begin
  1457.   if not islocked then 
  1458.       OKbox('Severe Error - Attempted to save Job Info not previously locked')
  1459.     else begin
  1460.         if recnum>0 then jobs.go(recnum)
  1461.         else jobs.append;
  1462.         jobs.ss('job_no',jobnum);
  1463.         jobs.ss('part_no',partnum);
  1464.         jobs.ss('rev_no',revnum);
  1465.         jobs.ss('joblink',joblink);
  1466.         jobs.ss('cust_ref',custref);
  1467.         jobs.dd('orderdate',orderdate);
  1468.         orevnum:=revnum;
  1469.         jobs.ss('cust_no',custnum);
  1470.         jobs.ss('ship_no',shipnum);
  1471.         jobs.ss('bill_to',billnum);
  1472.         jobs.ss('line_item',lineitem);
  1473.         jobs.ss('dep',depnum);
  1474.         jobs.ss('po_no',ponum);
  1475.         oponum:=ponum;
  1476.         jobs.ff('qty',qty);
  1477.         jobs.ff('org_qty',orgqty);
  1478.         oqty:=qty;
  1479.         jobs.ff('unit_price',uprice);
  1480.         ouprice:=uprice;
  1481.         jobs.dd('mot_date',motdate);
  1482.         omotdate:=motdate;
  1483.         jobs.ii('jstatus',jstatus);
  1484.         ojstatus:=jstatus;
  1485.         jobs.dd('statdate',statdate);
  1486.         ostatdate:=statdate;
  1487.         jobs.bb('taxable',taxable);
  1488.         if ourmat then jobs.ss('ourmat',' ')
  1489.         else jobs.ss('ourmat','C');
  1490.         jobs.ss('bar_fai',barfai);
  1491.         jobs.ss('waitstatus',waitstatus);
  1492.         jobs.ss('clozapprov',clozapprov);
  1493.         jobs.ss('lotmadeto',lotmadeto);
  1494.         jobs.ss('lotinspto',lotinspto);
  1495.         jobs.ss('lotshipto',lotshipto);
  1496.         jobs.ff('mater_est',mater_est);
  1497.         jobs.ff('proc_est',proc_est);
  1498.         jobs.ff('labor_est',labor_est);
  1499.         jobs.ff('bid',bid);
  1500.         jobs.ff('complete',complete);
  1501.         jobs.ff('partial',partial);
  1502.         jobs.ff('material',material);
  1503.         jobs.ii('matsel',matsel);
  1504.         jobs.ii('procsel',procsel);
  1505.         jobs.dd('setupdate',setupdate);
  1506.         jobs.dd('porecdate',porecdate);
  1507.         jobs.dd('lastchange',lastchange);
  1508.         jobs.ss('less',invless);
  1509.         if jipchg then begin
  1510.             if jipinfo.Seek(jobnum) then begin
  1511.                 jipinfo.lock;
  1512.             end else jipinfo.append;
  1513.             jipinfo.ss('job_no',jobnum);
  1514.             jipinfo.ss('buyer',buyer);
  1515.             jipinfo.bb('tobp',tobp);
  1516.             jipinfo.ss('less',tobpless);
  1517.             jipinfo.ss('rem1',ttrems[1]);
  1518.             jipinfo.ss('rem2',ttrems[2]);
  1519.             jipinfo.ss('rem3',ttrems[3]);
  1520.             jipinfo.ss('rem4',ttrems[4]);
  1521.             jipinfo.ss('rem5',ttrems[5]);
  1522.             jipinfo.ss('mat1',mat1);
  1523.             jipinfo.ss('mat2',mat2);
  1524.             jipinfo.unlock;
  1525.         end;
  1526.         totdue:=0;
  1527.         for ii:=1 to dcnt do begin
  1528.             totdue:=totdue+dqty[ii];
  1529.         end;
  1530.         if duechg then begin
  1531.             if dcnt>0 then begin
  1532.                 for ii:=1 to dcnt do begin
  1533.                     DoEvents2;
  1534.                     if drecs[ii]>0 then begin
  1535.                         due.Go(drecs[ii]);
  1536.                         due.Lock;
  1537.                     end else due.Append;
  1538.                     drecs[ii]:=due.RecNo;
  1539.                     due.ss('job_no',jobnum);
  1540.                     due.dd('fdate',ddates[ii]);
  1541.                     due.ff('qty',dqty[ii]);
  1542.                     due.unLock;
  1543.                 end;
  1544.             end;
  1545.             { purge leftover items, some may have been deleted }
  1546.             if ocnt>dcnt then begin
  1547.                 for ii:=dcnt+1 to ocnt do begin
  1548.                     if drecs[ii]>0 then begin
  1549.                         due.Go(drecs[ii]);
  1550.                         due.Lock;
  1551.                         drecs[ii]:=0;
  1552.                         due.ss('job_no',space(10));
  1553.                         due.unLock;
  1554.                     end;
  1555.                 end;
  1556.             end;
  1557.             { clear status indicator }
  1558.             for ii:=1 to MaxDue do begin
  1559.                 dstat[ii]:=0;
  1560.             end;
  1561.             ocnt:=dcnt;
  1562.             { make original match new info }
  1563.             if ocnt>0 then begin
  1564.                 for ii:=1 to ocnt do begin
  1565.                     odqty[ii]:=dqty[ii];
  1566.                     odates[ii]:=ddates[ii];
  1567.                 end;
  1568.             end;
  1569.             totship:=0;
  1570.             for ii:=1 to scnt do begin
  1571.                 totship:=totship+sqty[ii];
  1572.             end;
  1573.             if shipchg then begin
  1574.                 if scnt>0 then begin
  1575.                     for ii:=1 to scnt do begin
  1576.                         DoEvents2;
  1577.                         if srecs[ii]>0 then begin
  1578.                             ship.Go(srecs[ii]);
  1579.                             ship.Lock;
  1580.                         end else ship.Append;
  1581.                         srecs[ii]:=ship.RecNo;
  1582.                         ship.ss('job_no',jobnum);
  1583.                         ship.dd('fdate',sdates[ii]);
  1584.                         ship.ff('qty',sqty[ii]);
  1585.                         ship.dd('inv_date',sinv[ii]);
  1586.                         ship.ss('ship_via',svia[ii]);
  1587.                         ship.ss('shipper_no',sshippr[ii]);
  1588.                         ship.unLock;
  1589.                     end;
  1590.                 end;
  1591.                 { purge leftover items, some may have been deleted }
  1592.                 if oscnt>scnt then begin
  1593.                     for ii:=scnt+1 to oscnt do begin
  1594.                         if srecs[ii]>0 then begin
  1595.                             ship.Go(srecs[ii]);
  1596.                             ship.Lock;
  1597.                             srecs[ii]:=0;
  1598.                             ship.ss('job_no',space(10));
  1599.                             ship.unLock;
  1600.                         end;
  1601.                     end;
  1602.                 end;
  1603.             end;
  1604.             oscnt:=scnt;
  1605.         end;
  1606.         { save job items }
  1607.         if itemschg then begin
  1608.             if jobitems.Seek(jobnum) then begin
  1609.                 for jj:=1 to 3 do jobrecs[jj]:=0;
  1610.                 jj:=0;
  1611.                 While (Not jobitems.Eof) And (jobitems.s('job_no')=jobnum) do begin
  1612.                     jj:=jj+1;
  1613.                     jobrecs[jj]:=jobitems.recno;
  1614.                     jobitems.Skip;
  1615.                 end;
  1616.                 for jj:=1 to 3 do begin
  1617.                     if specup[jj]>0 then begin
  1618.                         if jobrecs[jj]>0 then begin
  1619.                             jobitems.go(jobrecs[jj]);
  1620.                             jobitems.lock;
  1621.                         end else jobitems.append;
  1622.                         jobitems.ss('job_no',jobnum);
  1623.                         jobitems.ss('item',specitem[jj]);
  1624.                         jobitems.ss('descrip',speccom[jj]);
  1625.                         jobitems.ff('unit_price',specup[jj]);
  1626.                         jobitems.ss('itype',upper(specper[jj]));
  1627.                         jobitems.unlock;
  1628.                     end else begin
  1629.                         if jobrecs[jj]>0 then begin
  1630.                             jobitems.lock;
  1631.                             jobitems.ss('job_no',' ');
  1632.                             jobitems.unlock;
  1633.                         end;
  1634.                     end;
  1635.                 end;
  1636.             end;
  1637.         end;
  1638.         otherup:=0;
  1639.         otherchgs:=0;
  1640.         othertext:='';
  1641.         for ii:=1 to 3 do begin
  1642.             if (pin('L',specper[ii])) Or
  1643.                 (pin('1',specper[ii])) then begin  { lot charge }
  1644.                 otherchgs:=otherchgs+specup[ii];
  1645.                 if Gen.CanSeePrice then begin
  1646.                     othertext:=othertext+trim(speccom[ii])+' ($'+
  1647.                         ltrim(transform(specup[ii],
  1648.                             '999,999.99'))+')';
  1649.                 End Else
  1650.                 Begin
  1651.                     othertext:=othertext+trim(speccom[ii]);
  1652.                 End;
  1653.             End Else
  1654.             Begin
  1655.                 otherup:=otherup+specup[ii];
  1656.             End;
  1657.         end;
  1658.         FlagOff(jobnum,'J');
  1659.     { reset statuses back to unchanged }
  1660.       jobchg:=false;
  1661.         duechg:=false;
  1662.         shipchg:=false;
  1663.         jipchg:=false;
  1664.         itemschg:=false;
  1665.     jobs.unLock;
  1666.     end;
  1667. end;
  1668.  
  1669. procedure JobRec.quickinfo;
  1670. var tpartn,tst,tejob:string;
  1671.     ii,i:integer;
  1672.     lpp:Lpr;
  1673. begin
  1674.   lpp:=Lpr.create;
  1675.     tpartn:=trim(partnum);
  1676.     if Not empty(revnum) then begin
  1677.         tpartn:=tpartn+'  '''+trim(revnum)+'''';
  1678.     End;
  1679.   lpp.SetDestination;
  1680.     lpp.StartDoc(for8x11,trim(jobnum)+' Job Info');
  1681.     lpp.p(1,2,datehyph(xDate));
  1682.     tejob:=trim(jobnum);
  1683.     tst:='';
  1684.   for i:=1 to length(tejob) do tst:=tst+substr(tejob,i,1)+' ';
  1685.     lpp.p(1,35,tst);
  1686.     if empty(joblink) then begin
  1687.         lpp.p(1,71,upper(longtime));
  1688.     End Else
  1689.     Begin
  1690.         lpp.p(1,11,upper(longtime));
  1691.         tejob:='(Linked to Job '+trim(joblink)+')';
  1692.         lpp.p(1,79-length(tejob),tejob);
  1693.     End;
  1694.     lpp.p(2,2,replicate('=',77));
  1695.     lpp.p(3,2,padc(trim(custname)+'  ('+trim(custnum)+')',76));
  1696.     lpp.p(4,2,'PART: ' + trim(tpartn)+'  '+trim(partname));
  1697.     lpp.p(5,2,'P.O.: ' +trim(ponum)+'    '+trim(custref));
  1698.     lpp.p(5,56,'DEPT: ' + Copy(upper(depname),1,16));
  1699.     lpp.p(6,2,' QTY:');
  1700.     lpp.p(6,8,ltrim(transform(qty,'999,999,999')));
  1701.     lpp.p(7,2,replicate('=',77));
  1702.     if jstatus>0 then begin
  1703.         if jstatus=1 then begin
  1704.             lpp.p(8,26,' ** JOB CANCELLED ');
  1705.         End Else
  1706.         if jstatus=2 then begin
  1707.             lpp.p(8,26,' ** JOB COMPLETED ');
  1708.         End Else
  1709.         if jstatus=3 then begin
  1710.             lpp.p(8,26,'  ** JOB CLOSED ');
  1711.         End;
  1712.         lpp.p(8,lpp.pCol,datehyph(statdate));
  1713.         lpp.p(8,lpp.pCol,' ** ');
  1714.     End;
  1715.     lpp.p(10,9,'DUE');
  1716.     lpp.p(10,16,'(Total ');
  1717.     lpp.p(lpp.pRow,lpp.pCol,ltrim(transform(totdue,'99,999,999'))+')');
  1718.     lpp.p(10,41,'SHIP');
  1719.     lpp.p(10,57,'(Total ');
  1720.     lpp.p(lpp.pRow,lpp.pCol,ltrim(transform(totship,'99,999,999'))+')');
  1721.     lpp.p(11,62,'Inv.    Ship');
  1722.     lpp.p(12,7,
  1723.         '  DATE         QUANTITY     LOT   DATE      QUANTITY   DATE     VIA');
  1724.     lpp.p(13,7,
  1725.         '  ----         --------     ---   ----      --------   ----     ---');
  1726.     ii:=dcnt;
  1727.     lpp.line := 14;
  1728.     if scnt>ii then begin
  1729.         ii := scnt;
  1730.     End;
  1731.     for i:=1 to ii do begin
  1732.         DoEvents2;
  1733.         if i<=dcnt then begin
  1734.             lpp.p(lpp.line,7,dshyph(ddates[i]));
  1735.             lpp.p(lpp.line,19,transform(dqty[i],'999,999,999'));
  1736.         End;
  1737.         if i<=scnt then begin
  1738.             if sinv[i]>0 then begin
  1739.                 lpp.p(lpp.line,36,slot[i]);
  1740.             End;
  1741.             lpp.p(lpp.line,39,datehyph(sdates[i]));
  1742.             lpp.p(lpp.line,48,transform(sqty[i],'999,999,999'));
  1743.             if Not empty(slot[i]) then begin
  1744.                 lpp.p(lpp.line,60,datehyph(sinv[i]));
  1745.                 lpp.p(lpp.line,71,svia[i]);
  1746.             End;
  1747.         End;
  1748.         lpp.line:=lpp.line+1;
  1749.     End;
  1750.     lpp.line:=lpp.line+1;
  1751.     if jstatus>0 then begin
  1752.         lpp.p(lpp.line,0,
  1753.             padc('(Balance Due '+ltrim(transform(0,'99,999,999'))+')',79));
  1754.     End Else
  1755.     Begin
  1756.         lpp.p(lpp.line,0,padc('(Balance Due '+
  1757.             ltrim(transform(totdue-totship,'99,999,999'))+')',79));
  1758.     End;
  1759.     lpp.crlf;
  1760.     lpp.StopDoc;
  1761.   lpp.free;
  1762. End;
  1763.  
  1764. procedure JCMainRec.LoadDepList;
  1765. var DepList:Tstringlist;
  1766.         ii:integer;
  1767. begin
  1768.   DepList:=Tstringlist.create;
  1769.     if Gen.AtPDS then begin
  1770.         DepList.LoadFromFile(compath('pdsdepts.dat'));
  1771.     End Else
  1772.     Begin
  1773.         DepList.LoadFromFile(compath('pgdepts.dat'));
  1774.     End;
  1775.     depcnt:=0;
  1776.     if DepList.Count>0 then begin
  1777.         for ii:=0 to deplist.count-1 do begin
  1778.           if ii<high(depname) then begin
  1779.                 split(deplist[ii],':',pars,parscnt);
  1780.                 if (parscnt=2) and (depcnt<MaxDeps) then begin
  1781.                   depcnt:=depcnt+1;
  1782.                     depcode[depcnt]:=padr(pars[1],3);
  1783.                     depname[depcnt]:=pars[2];
  1784.                 End;
  1785.             end;
  1786.         end;
  1787.     end;
  1788.   DepList.free;
  1789. end;
  1790.  
  1791. function JCMainRec.vdiv( dnum:string ):boolean;
  1792. { VDIV, valid Division }
  1793. begin
  1794.   if dnum='1 ' then begin
  1795.     Result:=True;
  1796.   End Else
  1797.   if (dnum='2 ') And (Gen.AtPDS) then begin
  1798.     Result:=True;
  1799.   End;
  1800.   Result:=False;
  1801. end;
  1802.  
  1803.  
  1804. function JCMainRec.ndiv( dnum:string ):string;
  1805. { NDIV, name of Division }
  1806. begin
  1807.   if dnum='1 ' then begin
  1808.     Result:='Arizona ';
  1809.   End Else
  1810.   if (dnum='2 ') And (Gen.AtPDS) then begin
  1811.     Result:='California ';
  1812.   End;
  1813.   Result:='* Div. Unknown *';
  1814. end;
  1815.  
  1816.  
  1817. function JCMainRec.rngdep( subnum:integer ):string;
  1818. { RNGDEP, get Dept. position in Dept list. }
  1819. begin
  1820.   Result:=' ';
  1821.   if (subnum>0) And (subnum<=Depcnt) then begin
  1822.     Result:=depcode[subnum];
  1823.   End;
  1824. end;
  1825.  
  1826.  
  1827. function JCMainRec.vdep( dnum:integer ):boolean;
  1828. { VDEP, is valid Dept number? }
  1829. begin
  1830.   Result:=False;
  1831.   if (dnum>0) and (dnum<=depcnt) then begin
  1832.     Result:=True;
  1833.   End;
  1834. end;
  1835.  
  1836.  
  1837. function JCMainRec.pdep( dnum:string ):integer;
  1838. { PDEP,  return Dept code to position }
  1839. var ddi,ddk:integer;
  1840. begin
  1841.   ddk:=0;
  1842.   for ddi:=1 to depcnt do begin
  1843.     if dnum=depcode[ddi] then begin
  1844.       ddk:=ddi;
  1845.       break;
  1846.     End;
  1847.   End;
  1848.   Result:=ddk;
  1849. end;
  1850.  
  1851.  
  1852. function JCMainRec.ndep( dnum:string ):string;
  1853. { NDEP,  return Dept title to position }
  1854. var ddi,ddj:integer;
  1855. begin
  1856.   ddj:=0;
  1857.   Result:='* Dept. Unknown *';
  1858.   for ddi:=1 to depcnt do begin
  1859.     if dnum=depcode[ddi] then begin
  1860.       ddj:=ddi;
  1861.       break;
  1862.     End;
  1863.   End;
  1864.   if ddj>0 then begin
  1865.     Result:=depname[ddj];
  1866.   End;
  1867. end;
  1868.  
  1869.  
  1870.  
  1871. End.
  1872.